﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.franchise.display {
    import flash.display.*;
    import org.aswing.*;
    import Classes.*;
    import Display.aswingui.*;

    public class StarRatingComponent extends JPanel {

        public static var NONE:Number = -2;
        public static var DISABLED:Number = -1;
        private static var MAX_RATING:int = 5;

        private var m_rating:Number;
        private var m_useBigStars:Boolean = false;

        public function StarRatingComponent(_arg1:Number, _arg2:Boolean=false){
            super(new SoftBoxLayout(SoftBoxLayout.X_AXIS, (_arg2) ? -5 : 0, SoftBoxLayout.LEFT));
            this.m_rating = _arg1;
            this.m_useBigStars = _arg2;
            this.draw(_arg1);
        }
        public function setStarRating(_arg1:Number):void{
            if (_arg1 != this.m_rating){
                this.m_rating = _arg1;
                this.draw(_arg1);
            };
        }
        private function draw(_arg1:Number):void{
            var _local3:Component;
            append(ASwingHelper.horizontalStrut(2));
            var _local2:int;
            while (_local2 < MAX_RATING) {
                _local3 = null;
                if (_arg1 == NONE){
                    _local3 = this.createNoStarComponent();
                } else {
                    if (_arg1 == DISABLED){
                        _local3 = this.createDisabledStarComponent();
                    } else {
                        _local3 = this.createStarComponent(Math.min((_arg1 - _local2), 1));
                    };
                };
                if (_local3){
                    append(_local3);
                };
                _local2++;
            };
            ASwingHelper.prepare(this);
        }
        private function createStarComponent(_arg1:Number):Component{
            var _local2:DisplayObject;
            if (_arg1 <= 0){
                _local2 = (this.m_useBigStars) ? (new (FranchiseMenuUI.m_assetDict["fr_star_empty"])() as DisplayObject) : new EmbeddedArt.fr_tooltip_star_empty();
                _local2.alpha = 0.5;
            } else {
                if (_arg1 >= 1){
                    _local2 = (this.m_useBigStars) ? (new (FranchiseMenuUI.m_assetDict["fr_star_full"])() as DisplayObject) : new EmbeddedArt.fr_tooltip_star_full();
                } else {
                    _local2 = (this.m_useBigStars) ? (new (FranchiseMenuUI.m_assetDict["fr_star_full"])() as DisplayObject) : new EmbeddedArt.fr_tooltip_star_full();
                };
            };
            var _local3:Component = new AssetPane(_local2);
            ASwingHelper.prepare(_local3);
            return (_local3);
        }
        private function createDisabledStarComponent():Component{
            var _local1:DisplayObject = (this.m_useBigStars) ? (new (FranchiseMenuUI.m_assetDict["fr_star_disabled"])() as DisplayObject) : new EmbeddedArt.fr_tooltip_star_empty();
            _local1.alpha = 0.5;
            var _local2:Component = new AssetPane(_local1);
            ASwingHelper.prepare(_local2);
            return (_local2);
        }
        private function createNoStarComponent():Component{
            return (null);
        }

    }
}//package Modules.franchise.display 
